<@page.html title="私教换教练">
<script type="text/javascript" src="${_appPath!}/js/cal.js"></script>
<script type="text/javascript">
  function save() {
    var fm = getEl("fm_input");
    post(fm);
  }
  function getptc(c) {
    if(c!="") {
      getJson("getPtContract?code="+c, function(data){
        if(data.ret) {
          var mc = data.data;
          var fm = getEl("fm_input");
          fm.contractCode.value = mc.contractCode;
          fm.saleDate.value = getDateStr(new Date(mc.saleDate));
          fm.saleType.value = mc.saleType+" - "+mc.saleTypeName;
          fm.memberCode.value = mc.memberCode;
          fm.memberName.value = mc.memberName;
          fm.contractItem.value = mc.ptCode+" - "+mc.ptCodeName;
          fm.contractCoach.value = mc.coachCode+" - "+mc.coachName;
          fm.contractBegin.value = getDateStr(new Date(mc.beginTime));
          fm.contractEnd.value = getDateStr(new Date(mc.endTime));
          fm.factAmount.value = formatMoney(mc.factPrice);
          fm.payAmount.value = formatMoney(mc.payAmount);
          fm.contractQuantity.value = mc.quantity;
          fm.leftQuantity.value = mc.leftQuantity;
        } else {
          window.alert(data.msg);
          clptc();
        }
      });
    }
  }
  function clptc() {
    var fm = getEl("fm_input");
    //fm.contractCode.value = "";
    fm.saleDate.value = "";
    fm.saleType.value = "";
    fm.memberCode.value = "";
    fm.memberName.value = "";
    fm.contractItem.value = "";
    fm.contractCoach.value = "";
    fm.contractBegin.value = "";
    fm.contractEnd.value = "";
    fm.factAmount.value = "";
    fm.payAmount.value = "";
    fm.contractQuantity.value = "";
    fm.leftQuantity.value = "";
  }

 </script>
<div style="width:600px;">

  <form id="fm_input" method="post" action="_add" onsubmit="return post(this);">
    <div class="kbox">
      <table class="input w4">
        <tr>
          <th width="85">私教合同号</th>
          <td width="160"><input type="text" name="contractCode" value="" req="私教合同号" onchange="getptc(this.value);" maxlength="20"></td>
          <th width="85"></th>
          <td width="160"></td>
        </tr>
        <tbody style="border:3px solid #ffefce;">
        <tr>
          <th>销售日期</th>
          <td><input type="text" name="saleDate" value="" class="date disable" maxlength="10" readonly></td>
          <th>销售类别</th>
          <td><input type="text" name="saleType" value="" class="disable" readonly></td>
        </tr>
        <tr>
          <th>会员姓名</th>
          <td><input type="text" name="memberName" value="" maxlength="10" class="disable" readonly></td>
          <th>会员编号</th>
          <td><input type="text" name="memberCode" value="" class="disable" readonly></td>
        </tr>
        <tr>
          <th>课程</th>
          <td colspan="3"><input type="text" name="contractItem" value="" class="w2 disable" readonly></td>
        </tr>
        <tr>
          <th>教练</th>
          <td colspan="3"><input type="text" name="contractCoach" value="" class="w2 disable" readonly></td>
        </tr>
        <tr>
          <th>合同起日</th>
          <td><input type="text" name="contractBegin" value="" class="date disable" maxlength="10" readonly></td>
          <th>合同迄日</th>
          <td><input type="text" name="contractEnd" value="" class="date disable" maxlength="10" readonly></td>
        </tr>
        <tr>
          <th>合同金额</th>
          <td><input type="text" name="factAmount" value="" class="disable" readonly></td>
          <th>付款金额</th>
          <td><input type="text" name="payAmount" value="" class="disable" readonly></td>
        </tr>
        <tr>
          <th>合同课时</th>
          <td><input type="text" name="contractQuantity" value="" class="disable" readonly></td>
          <th>剩余课时</th>
          <td><input type="text" name="leftQuantity" value="" class="disable" readonly></td>
        </tr>
        </tbody>

        <tr>
          <th>选择教练</th>
          <td colspan="3"><select name="newCoachCode" class="w2" req="新教练"><option value="">--请选择--</option><#if coachList??><#list coachList as t><option value="${t.code!}">${t.code!} - ${t.chName!} - <@value type="coachLevel" key="${t.coachLevel!}"/></option></#list></#if></select></td>
        </tr>
        <tr>
          <th>备注</th>
          <td colspan="3"><textarea name="note"></textarea></td>
        </tr>
      </table>
    </div>
    <div class="button"><input type="button" value="确认并提交" onclick="save();"></div>
  </form>
</div>
</@page.html>
